<?php
/**
 * 接口
 */
namespace app\manage\controller\operate;

use app\manage\controller\Base;

class Handle extends Base
{

	private $params;
    public function __construct(){
        parent::__construct();
        // token验证
        // if(false == Base::checkToken()){
        //     $this->error('token error!');
        // }
        // 参数去token
        $params = input('post.');
        unset($params['token']);
        $this->params = $params;
    }

    /**
     * 导出资产变动记录
     * @return [type] [description]
     */
    public function export_index(){
    	$params = $this->params;

    	$where = parseWhere($params);
    	$query = new \app\common\query\MemberCoinRecord;
    	$datas = $query->getDatas($where,['id','mid','coin_id','operate','amount','remark','flag','before_amount','after_amount','create_time']);

    	$excelData = "记录编号\t用户编号\t货币类型\t记录类型\t增减标识\t金额\t说明\t交易前\t交易后\t时间\t\n";
    	foreach($datas as $value):
    		$excelData .= $value['id']."\t";
            $excelData .= $value['mid']."\t";
            $excelData .= $value['coin_name']."\t";
            $excelData .= $value['operate_remark']."\t";
            $excelData .= $value['flag_remark']."\t";
            $excelData .= $value['amount']."\t";
            $excelData .= $value['remark']."\t";
            $excelData .= $value['before_amount']."\t";
            $excelData .= $value['after_amount']."\t";
            $excelData .= $value['create_date']."\t";
			$excelData .= "\n";
    	endforeach;
    	$excelData = iconv('utf-8','gb2312',$excelData);

    	exportExcel(time().'.xls',$excelData);
    }

}